//
//  DZMRMSettingView.swift
//  DZMeBookRead
//
//  Created by 邓泽淼 on 2017/5/11.
//  Copyright © 2017年 DZM. All rights reserved.
//

import UIKit
class NavigationView: UIView {
    var leftBtn = UIButton()
    var bookMarkBtn = UIButton()
    
    var leftPop:(() -> Void)?
    var bookMark:(() -> Void)?
    
    var changeSoureBtn = UIButton()
    var changeSoure:(()->Void)?
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupUI() {
        addSubview(leftBtn)
        addSubview(bookMarkBtn)
        addSubview(changeSoureBtn)
        leftBtn.setImage(UIImage.init(named: "globar_return"), for: .normal)
        leftBtn.addTarget(self, action: #selector(clickLeftBtn), for: .touchUpInside)
        
        bookMarkBtn.setImage(UIImage.init(named: "RM_17"), for: .normal)
        bookMarkBtn.setImage(UIImage.init(named: "RM_18"), for: .highlighted)
        bookMarkBtn.addTarget(self, action: #selector(clickBookMark), for: .touchUpInside)
        changeSoureBtn.setTitle("切换", for: .normal)
        changeSoureBtn.setTitleColor(UIColor.white, for: .normal)
        changeSoureBtn.setTitleColor(UIColor.red, for: .highlighted)
        changeSoureBtn.addTarget(self, action: #selector(clickChageSoure), for: .touchUpInside)
        
        
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        leftBtn.frame = CGRect.init(x: 22, y: 32, width: 22, height: 22)
        leftBtn.extendEdgeInsets = UIEdgeInsetsMake(20, 20, 20, 20)
        bookMarkBtn.frame = CGRect.init(x: ScreenWidth - 44, y: 32, width: 22, height: 22)
        changeSoureBtn.frame = CGRect.init(x: bookMarkBtn.frame.maxX - 80, y: 32, width: 40, height: 22)
        changeSoureBtn.extendEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 0)
    }
    /// 左手返回控制器
    func clickLeftBtn() {
        /// 丢给控制器去玩泥巴
        leftPop?()
}
    
    func clickBookMark() {
        bookMark?()
    }
    
    
    /// 改变换数据
    func clickChageSoure() {
        /// 给控制器去搞跳转
        changeSoure?()
    }
    
}
class DZMRMSettingView: UIView {

    /// 颜色
    private(set) var colorView:DZMRMColorView!

    /// 字体
    private(set) var fontView:DZMRMFuncView!
    
    /// 字体大小
    private(set) var fontSizeView:DZMRMFuncView!


    private(set) var spacingView:WJSpacingView!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    /// 添加控件
    func setupUI() {
        
         backgroundColor = DZMMenuUIColor
        // 颜色
        colorView = DZMRMColorView(frame:CGRect(x: 0, y: 0, width: ScreenWidth, height: 74),colors:DZMReadBGColors,selectIndex:DZMReadConfigure.shared().colorIndex)//
         addSubview(colorView)

//
        fontView = DZMRMFuncView(frame:CGRect(x: 0, y: colorView.frame.maxY, width: ScreenWidth, height: 50), funcType: .font, title:"字体", labels:["系统","娃娃体","翩翩体","楷书"], selectIndex:DZMReadConfigure.shared().fontType)
         addSubview(fontView)

        fontSizeView = DZMRMFuncView.init(frame: CGRect.init(x: 0, y: fontView.frame.maxY, width: ScreenWidth, height: 50), funcType: .fontSize, title: "字号", labels: [""], selectIndex: 0)
//
        spacingView = WJSpacingView.init(frame: CGRect.init(x: 0, y: fontSizeView.frame.maxY + 12, width: ScreenWidth, height: 44))

        addSubview(fontSizeView)
        addSubview(spacingView)
    }

}

